home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / docs / misc / ConcNews.lha / news / general.programming / comp.lang.c_12260_000017.msg < prev    next >
Encoding:
Text File  |  1994-11-27  |  1.9 KB  |  42 lines

  1. Newsgroups: comp.lang.c++,comp.lang.c
  2. From: fred@genesis.demon.co.uk (Lawrence Kirby)
  3. Path: dd.chalmers.se!news.chalmers.se!sunic!pipex!demon!genesis.demon.co.uk!fred
  4. Subject: Re: Here's a neat idiom for y'all...
  5. References: <CMu245.DE3@marin.cc.ca.us> <2mb4hs$4vs@crl.crl.com>  <lfw.763998847@pssparc2.oc.com> <2mdapj$9ph@crl2.crl.com> <EJH.94Mar21140731@larry.gsfc.nasa.gov> <2ml75l$d00@chico.staf.phil.ruu.nl> <1994Mar22.163726.18125@mksol.dseg.ti.com>
  6. Organization: none
  7. Reply-To: fred@genesis.demon.co.uk
  8. X-Newsreader: Demon Internet Simple News v1.27
  9. Lines: 27
  10. Date: Tue, 22 Mar 1994 20:16:35 +0000
  11. Message-ID: <764367395snz@genesis.demon.co.uk>
  12. Sender: usenet@demon.co.uk
  13. Xref: dd.chalmers.se comp.lang.c++:14076 comp.lang.c:12260
  14.  
  15. In article <1994Mar22.163726.18125@mksol.dseg.ti.com>
  16.            mccall@mksol.dseg.ti.com "Fred McCall" writes:
  17.  
  18. >: ANd besides, any half-decent compiler will emit a warning on construct like
  19. >: "if (a = b)", so the probelm is non-existent to begin with.
  20. >
  21. >I hate compilers that do this.  It's one of those messages I turn off
  22. >(because this isn't a mistake that I, personally, make -- I make other
  23. >mistakes, instead -- and because there are a lot of times when I *am*
  24. >doing an assignment in the conditional clause and I don't want my real
  25. >errors obscured by a bunch of noisy warnings).
  26.  
  27. It's common to add an extra set of parentheses to indicate that this is what
  28. was really intended as in:
  29.  
  30. if ((a = b))
  31.  
  32. Compilers like gcc recognise this and suppress the warning. It also makes
  33. things much clearer to somebody else maintaining the code. It's quite natural
  34. for assignments in expressiojns to be parenthesised e.g.
  35.  
  36. if ((ch = getchar()) == EOF)
  37.  
  38. -----------------------------------------
  39. Lawrence Kirby | fred@genesis.demon.co.uk
  40. Wilts, England | 70734.126@compuserve.com
  41. -----------------------------------------
  42.